/*    */ package com.qmsk.business.info.shopBrand.controller;
/*    */ 
/*    */ import com.qmsk.business.info.shopBrand.dao.ShopBrandDAO;
/*    */ import com.utils.gson.out.GsonEbRst;
/*    */ import com.utils.jdbc.connection.DbConnection;
/*    */ import com.utils.web.RequestUtils;
/*    */ import com.utils.web.ResponseUtils;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.transaction.annotation.Transactional;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"/shopBrand"})
/*    */ public class ShopBrandController
/*    */ {
/* 30 */   private static final Logger logger = Logger.getLogger(ShopBrandController.class);
/*    */ 
/*    */   @Autowired
/*    */   private ShopBrandDAO dao;
/*    */ 
/*    */   @RequestMapping(value={"find/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public void getListOfshopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId)
/*    */   {
/*    */     try
/*    */     {
/* 44 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId);
/* 45 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*    */     } catch (SQLException e) {
/* 47 */       logger.error(e);
/* 48 */       ResponseUtils.setErrorMsgResponse(
/* 49 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"insert/List"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void insertList(HttpServletRequest request, HttpServletResponse response)
/*    */   {
/* 60 */     String sJson = RequestUtils.getString(request, "data");
/* 61 */     int nUpdates = -1;
/*    */     try {
/* 63 */       this.dao.deleteListPk(sJson);
/* 64 */       nUpdates = this.dao.insertList(sJson);
/* 65 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 66 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 67 */         response);
/*    */     } catch (SQLException e) {
/* 69 */       logger.error(e);
/* 70 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 71 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 72 */         response);
/*    */     } finally {
/* 74 */       if (nUpdates <= -1)
/* 75 */         DbConnection.rollback();
/*    */       else
/* 77 */         DbConnection.commit();
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"delete/List"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void deleteList(HttpServletRequest request, HttpServletResponse response)
/*    */   {
/* 89 */     int nUpdates = -1;
/* 90 */     String sJson = RequestUtils.getStringOfId(request);
/*    */     try {
/* 92 */       nUpdates = this.dao.deleteList(sJson);
/* 93 */       DbConnection.commit();
/* 94 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 95 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 96 */         response);
/*    */     } catch (SQLException e) {
/* 98 */       DbConnection.rollback();
/* 99 */       logger.error(e);
/* 100 */       ResponseUtils.setErrorMsgResponse(
/* 101 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 102 */         e.getMessage(), response);
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.shopBrand.controller.ShopBrandController
 * JD-Core Version:    0.5.3
 */